package com.ck.chuangke.service.impl;

import com.ck.chuangke.service.CkProgramService;
import com.ck.dao.ProgramMapper;
import com.ck.model.chuangke.vo.CkProgramExportVO;
import com.ck.model.chuangke.vo.CkProgramListVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 节目
 *
 * @author linqiang
 * @date 2018-06-20 18:30
 */
@Service(value = "ckProgramService")
public class CkProgramServiceImpl implements CkProgramService {

    @Autowired
    private ProgramMapper programMapper;

    @Override
    public Page<CkProgramListVO> listByPage(Integer programStatus, String companyCode, String programName,
                                            Long startTime, Long endTime, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return programMapper.listByPageCk(programStatus, companyCode, programName, startTime, endTime);
    }

    /**
     * 获取节目总数
     * @return
     */
    @Override
    public Long getProgramCount() {
        return programMapper.getProgramCount(null);
    }

    /**
     * 根据节目状态查询节目总数
     * @param status 0：已审批，1：待审批，2：待发布，3：已过期
     * @return
     */
    @Override
    public Long getProgramCountByStatus(Integer status) {
        return programMapper.getProgramCount(status);
    }

    /**
     * 根据大区查询节目总数
     * @param region 大区：东北NE，华北NC，华中CC，华东EC，华南SC，西北WN，西南WS
     * @return
     */
    @Override
    public Long getProgramCountByRegion(String region) {
        return programMapper.getProgramCountByRegion(region);
    }

    /**
     * 导出创客节目列表
     *
     * @param programStatus 节目状态
     * @param companyCode   商家编号
     * @param programName   节目名称
     * @param startTime     更新开始时间
     * @param endTime       更新结束时间
     * @return List<CkProgramExportVO>
     */
    @Override
    public List<CkProgramExportVO> listExportProgramCk(Integer programStatus, String companyCode, String programName, Long startTime, Long endTime) {
        return programMapper.listExportProgramCk(programStatus, companyCode, programName, startTime, endTime);
    }

}
